
var t = null;
t = setTimeout(time, 1000); //開始运行
function time() {
    clearTimeout(t); //清除定时器
    dt = new Date();
    var xingqi = dt.getDay(); // 星期
    var weeks = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
    var week = weeks[xingqi]; // week  就是星期
    var y = dt.getFullYear();
    var mt = dt.getMonth() + 1;
    var mt2 = mt < 10 ? '0' + mt : mt;
    var day = dt.getDate();
    var h = dt.getHours(); //获取时
    var m = dt.getMinutes(); //获取分
    var m2 = m < 10 ? '0' + m : m;

    var s = dt.getSeconds(); //获取秒
    var s2 = s < 10 ? '0' + s : s;

    var times2 = h +
        ":" +
        m2 +
        ":" +
        s2;
    document.querySelector(".showTime").innerHTML =

    "<span style='font-size: 26px;'>" +
        "&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp" +
        "" +
        y +
        "." +
        mt2 +
        "." +
        day + "&nbsp;&nbsp;" + times2 + "&nbsp&nbsp;&nbsp&nbsp;" + week +"</span>";
    t = setTimeout(time, 1000); //设定定时器，循环运行
}
